package p.jce;

import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.KeyStoreSpi;
import java.security.NoSuchProviderException;
import java.security.Provider;

public class RKeyStore {
	private static class X extends KeyStore {

		protected X(KeyStoreSpi keyStoreSpi, Provider provider, String type) {
			super(keyStoreSpi, provider, type);
		}
	}

	public static KeyStore getInstance(String algorithm) throws KeyStoreException {
		return KeyStore.getInstance(algorithm);
	}

	public static KeyStore getInstance(String algorithm, String provider) throws KeyStoreException,
			NoSuchProviderException {
		if ("BC".equals(provider)) {
			try {
				return new X((KeyStoreSpi) BC.newInstance("KeyStore", algorithm), null, algorithm);
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return KeyStore.getInstance(algorithm, provider);
	}

	public static KeyStore getInstance(String algorithm, Provider provider) throws KeyStoreException {
		return KeyStore.getInstance(algorithm, provider);
	}

}
